using System;
using XDQ.VAT.Permissions;
using XDQ.VAT.Exams.Dtos;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Features;
using XDQ.VAT.Settings;
using System.Threading.Tasks;
using System.Collections.Generic;
using Microsoft.Extensions.DependencyInjection;
using XDQ.VAT.Classes;
using XDQ.VAT.Courses;

namespace XDQ.VAT.Exams
{
    [RequiresFeature(VATFeatures.Exam.Default)]
    public class AppExamAppService : CrudAppService<AppExam, AppExamDto, Guid, PagedAndSortedResultRequestDto, CreateUpdateAppExamDto, CreateUpdateAppExamDto>,
        IAppExamAppService
    {
        protected override string GetPolicyName { get; set; } = VATPermissions.AppExam.Default;
        protected override string GetListPolicyName { get; set; } = VATPermissions.AppExam.Default;
        protected override string CreatePolicyName { get; set; } = VATPermissions.AppExam.Create;
        protected override string UpdatePolicyName { get; set; } = VATPermissions.AppExam.Update;
        protected override string DeletePolicyName { get; set; } = VATPermissions.AppExam.Delete;

        private readonly IAppExamRepository _repository;

        public AppExamAppService(IAppExamRepository repository) : base(repository)
        {
            _repository = repository;
        }

        public Task<List<SelectListItemDto>> GetClassesAsync()
        {
            var repository = ServiceProvider.GetRequiredService<IAppClassRepository>();
            return repository.GetSelectListsAsync();
        }

        public Task<List<SelectListItemDto>> GetCoursesAsync()
        {
            var repository = ServiceProvider.GetRequiredService<IAppCourseRepository>();
            return repository.GetSelectListsAsync();            
        }
    }
}
